Skip to content

Belief-free generator search over HMM symbol matrices as a pipeline stage - #69

Merged
Autoplectic merged 1 commit into
mainfrom
belief-free-hmm-search
Nov 18, 2026
Merged

Autoplectic merged 1 commit into
mainfrom
belief-free-hmm-search

Conversation

@Autoplectic

Copy link
Copy Markdown
Member

Summary

  • New module sofic.generators.hmm_search:
    • hmm_generator_search(machine, k, starts=..., rng=..., deadline=...) optimizes the symbol matrices of a k-state HMM directly (softmax rows). It minimizes the state entropy H[pi] subject to exact word probabilities for all words up to length k + |S+|. Agreement up to that length implies agreement on all words (Tzeng 1992), so feasible points are generators.
    • It uses an augmented Lagrangian with analytic gradients: reverse mode through the forward recursion on the word tree, with the stationary law differentiated through the fundamental matrix (pseudo-inverse fallback for reducible chains). Feasibility comes first from a random start, then entropy descent.
    • coupled_seed_from_hmm(problem, matrices) recovers the coupled form (pi, Q, R, K) from the product chains of the HMM with the forward and reverse causal states, so results feed the existing candidate/verification path.
  • generative_model / generative_model_from_bidirectional get a new stage "hmm" (in the default stages) after the coupled search, controlled by hmm_search=True and hmm_search_starts=8. With a time budget it tries k = |S+| .. |S+| + 2 with half the remaining budget. Without one it tries k = |S+|, |S+| + 1 with two starts, about 5 s on 3-state machines.

Why

The coupled searches parameterize generator states by their causal-state beliefs (Q_w, R_w). That parameterization never reached generators whose states' pasts or futures are not belief-mixtures of the causal states'. On the 96 open C_g brackets of the binary 2-/3-state dataset, a prototype of this search lowered seven upper bounds, all word-verified:

process old upper new upper states
n3-t122-d2 0.9037 (= C_mu) 0.7956 4
n3-t140-d3 1.5142 1.4010 5
n3-t140-d4 1.3202 1.2540 5
n3-t010-d1 1.3578 1.3197 5
n3-t122-d1 1.3089 1.2868 4
n3-t053-d0 0.0982 0.0922 3
n3-t082-d0 1.4089 1.4087 3

While wiring the stage in, it also found a generator below the minimal functional generator on the interleaved process _interleaved(0.1) used in test_generative_model_offers_minimal_functional_generator. That test restricts stages=("functional",), which is why the stage is gated on "hmm" in stages.

Tests

  • test_objective_gradient_matches_finite_differences (hypothesis): analytic vs finite differences, with and without the entropy term.
  • test_search_returns_exact_generators: every result passes the exact difference-automaton check, satisfies the coupled equations, and has entropy at least the excess entropy.
  • test_search_beats_the_epsilon_machine_on_n3_t122_d2 (slow, about 10 s): k = 4 reaches below 0.80 (C_mu = 0.9037).
  • test_pipeline_stage_runs_and_can_be_disabled.
  • Full default suite locally: 2864 passed, 9 skipped (6 min, -n 12). The slowest pipeline tests are in line with main.

Docs (docs/generators/generative_models.rst, new paragraph and autofunction entries) and CHANGELOG are updated. Tzeng1992 and Ruebeck2018 were added to docs/references.bib; direct parameter search for minimal generators of binary Markov processes is the approach of Ruebeck et al. 2018.

Made with Cursor

…line stage

hmm_generator_search optimizes a k-state HMM's symbol matrices directly, minimizing the state
entropy under exact word equalities up to length k + |S+| (which imply equality on all words),
with an augmented Lagrangian and analytic gradients. The coupled searches parameterize states
by their causal-state beliefs and miss generators whose states' pasts or futures are not
belief-mixtures of the causal states'. On the 96 open brackets of the binary 3-state dataset
the search lowered seven upper bounds (e.g. n3-t122-d2 from 0.9037 to 0.7956).

generative_model runs it after the coupled search (stage 'hmm', hmm_search=True) for
k = |S+| .. |S+| + 2 with half the remaining budget, or two k and two starts without one.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Autoplectic
Autoplectic merged commit cc2895a into main Nov 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant